package cz.vitsol.dovweb.portlet.alert;

import java.io.Serializable;
import java.util.List;
import java.util.Vector;

/**
 * Nosic alertu 
 * @author pmalis
 *
 */
public class AlertBean implements Serializable {
	
	private static final long serialVersionUID = -3023713436123131435L;
	
	private final List<String[]> ALERT_LIST = new Vector<String[]>();
	
	public AlertBean () {
		
	}
	
	public void addAlert (String title, String content) {
		ALERT_LIST.add(new String[] {title, content});
	}
	
	public List<String[]> getAlerts () {
		return ALERT_LIST;
	}

	@Override
	public String toString() {
		
		StringBuffer sb = new StringBuffer();
		
		for (String[] ret : ALERT_LIST) {
			sb.append(ret[0]);
			sb.append(ret[1]);
		}
		
		return sb.toString();
		
	}
	
	/**
	 * Vraci title z prvniho zaznamu v seznamu, jinak "".
	 * @return
	 */
	public String getFirstTitle () {
		return ALERT_LIST.isEmpty() ? "" : ALERT_LIST.get(0)[0];
	}

	/**
	 * Vraci obsah z prvniho zaznamu v seznamu, jinak "".
	 * @return
	 */
	public String getFirstMsg () {
		return ALERT_LIST.isEmpty() ? "" : ALERT_LIST.get(0)[1];
	}
}
